package com.cloudbroker.openapi.manage.controller;

import com.cloudbroker.bcs.common.entity.HSBCPSBackVO;
import com.cloudbroker.bcs.common.util.VOUtil;
import com.cloudbroker.bcs.platform.ltb.bizapi.service.admin.back.RecommendRuleBack;
import com.cloudbroker.bcs.platform.ltb.bizapi.service.admin.vo.AdminRecommendQryForm;
import com.cloudbroker.bcs.platform.ltb.bizapi.service.admin.vo.AdminSaveRecommendRuleForm;
import com.cloudbroker.bcs.platform.ltb.bizapi.service.admin.vo.PublicManageUserSignQryForm;
import com.cloudbroker.bcs.platform.ltb.bizapi.t2service.admin.AdminRecommendRuleT2BizService;
import com.cloudbroker.bcs.platform.ltb.common.ext.annotation.SaveLog;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import static com.cloudbroker.bcs.platform.ltb.common.util.RequestUtil.getSingleParameterMapForBody;

/**
 * Created by world on 16/12/8.
 */
@Controller
public class RecommendRuleController {

    @Resource
    private AdminRecommendRuleT2BizService adminRecommendRuleT2BizService;

    @ResponseBody
    @RequestMapping("/manage/recommend_rule_add")
    @SaveLog(remark = "推荐规则添加")
    public HSBCPSBackVO saveRecommendRule(HttpServletRequest request, String jsonpcallback){
        AdminSaveRecommendRuleForm form = getSingleParameterMapForBody(request,AdminSaveRecommendRuleForm.class);
        return VOUtil.setJsonpResult(adminRecommendRuleT2BizService.saveRecommendRule(form),jsonpcallback);
    }

    @ResponseBody
    @RequestMapping("/manage/recommend_rule_qry")
    @SaveLog(remark = "推荐规则查询")
    public RecommendRuleBack recommendRuleQry(HttpServletRequest request, String jsonpcallback){
        AdminRecommendQryForm form = getSingleParameterMapForBody(request,AdminRecommendQryForm.class);
        return VOUtil.setJsonpResult(adminRecommendRuleT2BizService.recommendRuleQry(form),jsonpcallback);
    }
}
